import java.io.File;

import javax.servlet.ServletException;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.core.StandardServer;
import org.apache.catalina.startup.Tomcat;

public class TomcatServer {

	public static void main(String[] args) throws LifecycleException, ServletException {
		Tomcat tomcat = new Tomcat();  
        tomcat.setPort(80);  
        tomcat.setBaseDir(".");  
        StandardServer server = (StandardServer) tomcat.getServer();  
        AprLifecycleListener listener = new AprLifecycleListener();  
        server.addLifecycleListener(listener);  
        String baseDir = new File("web").getAbsolutePath();
        tomcat.addWebapp("/", baseDir);  
        tomcat.start();  
        tomcat.getServer().await();
	}
}
